import 'package:flutter/material.dart';
import 'package:flutter_swiper/flutter_swiper.dart';

const List<String> defaultImages = [
  'http://r0utoyzux.hn-bkt.clouddn.com/swiper.jpg',
  'http://r0utoyzux.hn-bkt.clouddn.com/swiper.jpg',
  'http://r0utoyzux.hn-bkt.clouddn.com/swiper.jpg',
];
var imageWidth = 750.0;
var imageHeight = 424.0;

class CommonSwipper extends StatelessWidget {
  final List<String> images;

  const CommonSwipper({Key key, this.images = defaultImages}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    var height = MediaQuery.of(context).size.width / imageWidth * imageHeight;
    return Container(
      height: height,
      child: new Swiper(
        itemBuilder: (BuildContext context, int index) {
          return new Image.network(
            images[index],
            fit: BoxFit.fill,
          );
        },
        itemCount: images.length,
        pagination: new SwiperPagination(),
        //control: new SwiperControl(),
        // viewportFraction: 0.8,
        // scale: 0.9,
        autoplay: true,
      ),
    );
  }
}
